package calorie.com.calorie.contact;


import android.content.Context;

import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;

import calorie.com.calorie.api.ApiService;
import calorie.com.calorie.constant.Constant;
import calorie.com.calorie.request.ProfitRecordRequest;
import calorie.com.calorie.response.ProfitRecordResponce;
import retrofit2.Call;
import retrofit2.Response;

public class ProfitRecordContact {
    public static class  ProfitRecordPresent extends BasePresent<IProfitRecordView> {
        public void queryProfiRecord(Context context, int pageNo){
            ApiService service= ServiceGenerator.createService(ApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            ProfitRecordRequest request=new ProfitRecordRequest(userId,pageNo);
            service.queryProfitRecord(request).enqueue(new NetCallBack<ProfitRecordResponce>() {
                @Override
                public void onSuccess(Call<ProfitRecordResponce> call, Response<ProfitRecordResponce> response) {
                    if (getView()!=null){
                        getView().getProfitRecordData(response);
                    }
                }

                @Override
                public void onFailed() {

                   // ToastUtils.showLongToast(context,"网络请求异常");

                }
            });
        }
    }

    public interface IProfitRecordView extends IBaseView {
        void getProfitRecordData(Response<ProfitRecordResponce> response);
    }
}
